package javabase.schoolwork.day6_6;

import java.util.ArrayList;
import java.util.List;

/**
 * @author fance
 * @date 18-6-6 下午4:39
 */

public class Person {
    private List<InfoForPerson> infoForPersonList;

    public Person() {
    }

    public Person(List<InfoForPerson> infoForPersonList) {
        this.infoForPersonList = infoForPersonList;
    }

    public List<InfoForPerson> getInfoForPersonList() {
        return infoForPersonList;
    }

    public void setInfoForPersonList(List<InfoForPerson> infoForPersonList) {
        this.infoForPersonList = infoForPersonList;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("Person{");
        for (InfoForPerson infoForPerson : infoForPersonList) {
            stringBuilder.append(infoForPerson.getInfo());
            stringBuilder.append(" : ");
            stringBuilder.append(infoForPerson.getVal());
            stringBuilder.append(",");
        }
        stringBuilder.append("}");
        return stringBuilder.toString();
    }

    public static void main(String[] args) {
        Person person = new Person();
        person.setInfoForPersonList(new ArrayList<>());
        person.getInfoForPersonList().add(new InfoForPerson("name","小黄"));
        person.getInfoForPersonList().add(new InfoForPerson("age",20));
        person.getInfoForPersonList().add(new InfoForPerson("sex","男"));

        System.out.println(person);
    }
}
